package com.hkts.management.unattended.master.service;

import com.hkts.management.common.utils.ResultUtil;
import com.hkts.management.unattended.order.entity.HktsOrderInfo;
import com.hkts.management.unattended.order.service.serviceimpl.HktsOrderInfoServiceImpl;
import com.hkts.management.unattended.order.service.serviceimpl.HktsOrderInfoSlaveServiceImpl;
import com.hkts.management.unattended.weightingInfo.entity.WeightingInfo;
import com.hkts.management.unattended.weightingInfo.service.serviceimpl.WeightingInfoServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Slf4j
public class MasterService {
    @Autowired
    private HktsOrderInfoServiceImpl orderInfoService;
    @Autowired
    private WeightingInfoServiceImpl weightingInfoService;
@Autowired
private HktsOrderInfoSlaveServiceImpl orderInfoSlaveService;
    /**
     * 必须master库方法执行，才能回滚，达到事务效果
     */
    @Transactional(rollbackFor = Exception.class)
    public void save(){
        HktsOrderInfo hktsOrderInfo=new HktsOrderInfo();
        hktsOrderInfo.setId("6");
        orderInfoService.save(hktsOrderInfo);
        WeightingInfo weightingInfo=new WeightingInfo();
        weightingInfo.setWeighingCode("4");
        weightingInfoService.save(weightingInfo);

    }
    public void select(){
        List<HktsOrderInfo> orderInfos= orderInfoService.selectList();
        List<HktsOrderInfo> orderInfo= orderInfoSlaveService.selectList();
    }
}
